package com.wanpinghui.wphlibrary.model.order.bean;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;
import java.util.List;

/**
 * 功能描述
 * author:caitiangui
 * time:2018/1/2
 */

public class OrderItemBean implements Parcelable {

    private int buyer_id; // (integer, optional),
    private String buyer_mobile; // (string, optional): 电话 ,
    private String buyer_name; // (string, optional): 购买人 ,
    private long created_at;   //创建时间
    private int id;                     //  主键id
    private boolean is_consult;         //(boolean, optional): 是否议价 ,
    private List<OrderGoodsItemBean> itemList;           // (Array[订单清单传输对象], optional): 订单清单 ,
    private String order_no;            //(string, optional): 订单编号 ,
    private List<OrderRemarkBean> remarkList;            // (Array[订单备注传输对象], optional): 订单备注 ,
    private double total;            // (number, optional): 总价 ,


    public int getId() {
        return id;
    }

    public boolean is_consult() {
        return is_consult;
    }

    public List<OrderGoodsItemBean> getItemList() {
        return itemList;
    }

    public String getOrder_no() {
        return order_no;
    }

    public List<OrderRemarkBean> getRemarkList() {
        return remarkList;
    }

    public double getTotal() {
        return total;
    }

    public long getCreated_at() {
        return created_at;
    }

    public String getBuyer_name() {
        return buyer_name;
    }

    public String getBuyer_mobile() {
        return buyer_mobile;
    }

    public int getBuyer_id() {
        return buyer_id;
    }

    public boolean isIs_consult() {
        return is_consult;
    }

    public String getSafeBuyerMobile() {
        String phone = null;
        if (buyer_mobile != null) {
            int length = buyer_mobile.length();
            phone = buyer_mobile.substring(0, 3) + "****" + buyer_mobile.substring(length - 4, length);
        }
        return phone;

    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.buyer_id);
        dest.writeString(this.buyer_mobile);
        dest.writeString(this.buyer_name);
        dest.writeLong(this.created_at);
        dest.writeInt(this.id);
        dest.writeByte(this.is_consult ? (byte) 1 : (byte) 0);
        dest.writeList(this.itemList);
        dest.writeString(this.order_no);
        dest.writeList(this.remarkList);
        dest.writeDouble(this.total);
    }

    public OrderItemBean() {
    }

    protected OrderItemBean(Parcel in) {
        this.buyer_id = in.readInt();
        this.buyer_mobile = in.readString();
        this.buyer_name = in.readString();
        this.created_at = in.readLong();
        this.id = in.readInt();
        this.is_consult = in.readByte() != 0;
        this.itemList = new ArrayList<OrderGoodsItemBean>();
        in.readList(this.itemList, OrderGoodsItemBean.class.getClassLoader());
        this.order_no = in.readString();
        this.remarkList = new ArrayList<OrderRemarkBean>();
        in.readList(this.remarkList, OrderRemarkBean.class.getClassLoader());
        this.total = in.readDouble();
    }

    public static final Creator<OrderItemBean> CREATOR = new Creator<OrderItemBean>() {
        @Override
        public OrderItemBean createFromParcel(Parcel source) {
            return new OrderItemBean(source);
        }

        @Override
        public OrderItemBean[] newArray(int size) {
            return new OrderItemBean[size];
        }
    };
}
